package com.patternsbox.behavioral.observer;

import java.util.ArrayList;
import java.util.List;

abstract class Subject {

	private List<Observer> observers = new ArrayList<Observer>();
	
	public abstract void setSubjectState(String state);
	public abstract String getSubjectState();

	public void attach(Observer observer) {
		observers.add(observer);
	}

	public void detach(Observer observer) {
		observers.remove(observer);
	}

	public void notifyObservers() {
		for (Observer o : observers) {
			o.update();
		}
	}
}
